package com.datastructure.test.recall.arrayoftotal;

import java.util.*;

public class Solution {
   static ArrayList<ArrayList<String>> res = new ArrayList<>();
    public static void main(String[] args) {
        Set<String> set;
        int result=0;
        Scanner scanner = new Scanner(System.in);
        String mems="";
        String skills="";
        int number=0;
        int index=0;
        while (scanner.hasNext()){
            if(index==0) {
                mems = scanner.nextLine();
            }
            if(index==1){
                skills = scanner.nextLine();
            }
            if(index==1){
                number = scanner.nextInt();
            }
            index++;
        }
        String s = skills.replaceAll("\\[", "");
        String s1 = s.replaceAll("\\]", "");
        String[] split = s1.split("\\,");
        ArrayList<ArrayList<String>> subsets = subsets(split);
        for (ArrayList<String> subset : subsets) {
            if(subset.size()>=number){
                set = new HashSet<>(subset);
                if(set.size()>=number){
                    result++;
                }
            }
        }
        System.out.println(result);
    }

    public static ArrayList<ArrayList<String>> subsets(String[] S) {
        LinkedList<String> track = new LinkedList<>();
        back(S, 0, track);
        return res;
    }
    public static void back(String[] S, int start, LinkedList<String> track){
        res.add(new ArrayList<>(track));
        for(int i = start; i < S.length; i++){
            track.add(S[i]);
            back(S, i+1, track);
            //撤销 回溯
            track.removeLast();
        }
    }
}
